<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        p {
            height: 600px;
            border: solid;
            font-size: 6rem;
        }
    </style>
</head>

<body>

    <p>p1</p>
    <p>p2</p>
    <p>p3</p>
    <p id="p4">p4</p>
    <p>p5</p>
    <p style="width: 1000px;">p6</p>
    <script>


        const p4 = document.getElementById('p4');

        setInterval(() => {
            // dom的顶部（top）和窗口（window）的顶部对齐
            // p4.scrollIntoView(true);//

            // dom的底部（bottom）和窗口（window）的底部对齐
            p4.scrollIntoView(false);//
        }, 4000);

    </script>
</body>

</html>